import React, { Component } from 'react'
import './Mine.less'
import Header from '../../components/Header/Header'
import {$pre} from '../../http/http'
import {reqgetbanner} from '../../http/api'
import {Swiper} from 'antd-mobile'
export default class Mine extends Component {
  constructor(){
    super()
    this.state={
      list:[],
      user:localStorage.getItem("isLogin") ? JSON.parse(localStorage.getItem("isLogin")) : {},
    }
  }
  componentDidMount(){
    this.getList();
  }
  async getList(){
    let {data:res} = await reqgetbanner();
    if(res.code ===200){
      let arr = res.list ? res.list : [];
      console.log(arr);
      this.setState({
        list:arr,
      })
    }
  }
  render() {
    let {user,list} =this.state
    return (
      <div className='mine'>
          <Header back title="我的"></Header>
          <div className='nickname'>用户：{user.nickname ? user.nickname : '暂无数据' }</div>
          <div className="banner">
            <Swiper loop autoplay>{list.map(item=>(
              <Swiper.Item key={item.id}>
              <div
                className={'content'}
              >
                <img src={$pre + item.img} alt="" />
              </div>
            </Swiper.Item>
            ))}</Swiper>


          </div>
      </div>
    )
  }
}
